package com.apes.scm.masterdata.product.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.party.model.PartyRole;
import com.apes.scm.masterdata.product.model.Product;
import com.apes.scm.masterdata.product.model.StarProduct;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @program: apes-server
 * @description:
 * @author: czs
 * @create: 2022-07-01 11:44
 **/
public interface StarProductRepository extends CustomRepository<StarProduct,  String> {

    List<StarProduct> findAllByStarPersonAndValidIsTrue(PartyRole starPerson);

    @Query("select p.product from StarProduct p where p.starPerson.id = :starPersonId and p.valid = true")
    List<Product> findAllProductByStarPerson(@Param("starPersonId") String starPersonId);

    StarProduct findByProductAndStarPerson(Product product, PartyRole partyRole);

}
